<!DOCTYPE html>
<!-- saved from url=(0052)http://getbootstrap.com/docs/4.0/examples/dashboard/ -->
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Dashboard Template for Bootstrap</title>
    <!-- Bootstrap core CSS -->
    <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link th:href="@{/css/dashboard.css}" rel="stylesheet">
    <style type="text/css">

        @-webkit-keyframes chartjs-render-animation {
            from {
                opacity: 0.99
            }
            to {
                opacity: 1
            }
        }

        @keyframes chartjs-render-animation {
            from {
                opacity: 0.99
            }
            to {
                opacity: 1
            }
        }

        .chartjs-render-monitor {
            -webkit-animation: chartjs-render-animation 0.001s;
            animation: chartjs-render-animation 0.001s;
        }
    </style>
</head>

<body>
<div th:replace="~{common/commonsUser::topbar}"></div>

<div class="container-fluid">
    <div class="row">
        <div th:replace="~{common/commonsUser::sidebar(active='findDepAtt.html')}"></div>

        <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
            <h2>培训考勤</h2>
            <form th:action="@{/findDepAtt}" method="post">
                <table>
                    <tr>
                        <th>
                            <div class="form-group">
                                <label>开课部门</label>
                                <!--提交的是部门的ID-->
                                <select class="" name="departmentid" id="departmentid" required style="width: 100px">
                                    <option value="">请选择部门</option>
                                    <option  th:each="dept:${departments}" th:text="${dept.departmentname}" th:value="${dept.id}">1</option>
                                </select>
                            </div>
                        </th>
                        <th>
                            <div class="form-group">
                                <label>课程名称</label>
                                <!--提交的是部门的ID-->
                                <select class="" name="courseid" id="courseid" required style="width: 100px">
                                    <option value="">请选择课程</option>
                                    <option  th:each="course:${courses}" th:text="${course.coursename}" th:value="${course.id}"></option>
                                </select>
                            </div>
                        </th>
                </table>
                <button type="submit" class="btn btn-primary">查询培训考勤</button>
            </form>
            <div class="table-responsive">
                <table class="table table-striped table-sm">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>职工姓名</th>
                        <th>身份证号</th>
                        <th>性别</th>
                        <th>年龄</th>
                        <th>联系电话</th>
                        <th>地址</th>
                        <th>邮箱</th>
                        <th>部门</th>
                        <th>职位</th>
                        <th>入职日期</th>
                    </tr>
                    </thead>
                    <input type="hidden" id="msg" th:value="${msg}" >
                    <input type="hidden" id="msgCode" th:value="${msgCode}" >
                    <tbody>
                    <tr th:each="emp:${emps}">
                        <td th:text="${emp.getId()}"></td>
                        <td th:text="${emp.getEmployeename()}"></td>
                        <td th:text="${emp.getIdcard()}"></td>
                        <td th:text="${emp.getSex() == 1 ? '男':'女'}"></td>
                        <td th:text="${emp.getAge()}"></td>
                        <td th:text="${emp.getTelephone()}"></td>
                        <td th:text="${emp.getAddress()}"></td>
                        <td th:text="${emp.getEmail()}"></td>
                        <td th:text="${emp.getDepartmentname()}"></td>
                        <td th:text="${emp.getPosition()}"></td>
                        <!--使用时间格式化工具-->
                        <td th:text="${#dates.format(emp.getDate(),'yyyy-MM-dd')}"></td>
                    </tr>

                    </tbody>
                </table>
            </div>
        </main>
    </div>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script type="text/javascript" th:src="@{/js/jquery-3.2.1.slim.min.js}"></script>
<script type="text/javascript" th:src="@{/js/popper.min.js}"></script>
<script type="text/javascript" th:src="@{/js/bootstrap.min.js}"></script>
<script type="text/javascript" th:src="@{/laydate/laydate.js}"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
<script type="text/javascript" th:src="@{/js/jquery.table2excel.js}"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/11.3.0/sweetalert2.all.min.js" integrity="sha512-HL3ljb5fSrMMfAiRxSP+EdI/KC1kl6gVIzCV7GaJ4yFWCpnrcGxPAmytnKk9KNigFhyICxOlgD+uuaS07t7RdQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
    //执行一个laydate实例
    laydate.render({
        elem: '#dateFormat',
        trigger:'click'//指定元素
    });
</script>
<script>
    $("#departmentid").change(function () {
        var departmentid = $("#departmentid").val();
        console.log(departmentid);
        if (departmentid == null) {
            return;
        }
        $.ajax({
            cache: true,
            type: "get",
            url: "http://localhost:8080/getCourseBydepid",
            data:{"departmentid":departmentid},
            success: function (data) {
                console.log("------------------"+data);
                var courseid = $("#courseid").empty();
                courseid.append('<option value="" required>请选择课程</option>');
                for (let i = 0; i < data.length; i++) {
                    courseid.append("<option value='"+data[i].id+"'>" + data[i].coursename + "</option>");
                }
            }
        })
    })
</script>
<script>
    $(function(){
        hint1();//页面加载时加载
    })
    function hint1(){
        // var message1=document.getElementById("msg1").value;
        // var messageCode1=document.getElementById("messageCode1").value;
        var msg1=$("#msg").val();//获取id为msg1隐藏域的value值
        var msgCode1=$("#msgCode").val();//获取Id为msgCode1隐藏域的value值
        console.log("msg:",msg1);
        console.log("messageCode:",msgCode1);
        if (msg1!=""&&msg1!=null){
            msg(msg1,msgCode1);
        }

    }
    function msg(mge,messageCode){

        if (messageCode == "200") {
            Swal.fire({
                icon: "success",
                title: "提示",
                text: mge,
                showConfirmButton: false,
                timerProgressBar: true,
                timer: 1500
            });
        } else {
            Swal.fire({
                icon: "error",
                title: "提示",
                text: mge,
                showConfirmButton: false,
                timerProgressBar: true,
                timer: 2500
            });
        }
    }
</script>
</body>
</html>